package com.jia.mybatis.page;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

import java.util.List;

@Data
public class PageResult<T> {
    private long current;
    private long size;
    private long total;
    private long totalPage;
    private List<T> records;

    public static <T> PageResult<T> convert(Page<T> page) {
        PageResult<T> result = new PageResult<T>();
        result.setCurrent(page.getCurrent());
        result.setSize(page.getSize());
        result.setTotal(page.getTotal());
        result.setTotalPage(page.getPages());
        result.setRecords(page.getRecords());
        return result;
    }

}
